(library (grid-gen common)
  (export comp-int comp-float comp-vector comp-array
          int-array float-array
          vec-var set-ind
          arr-loop arr-loop-d arr-loop-in-d do-loop
          arr-loop-in nop beg set-val do-while do-loop-in
          do-loop-d do-loop-in-d do-every main-p
          save-txt exp-ex cur-ptr print evl
          exp-sv exp-sv-local var-dims
          replace-el set-ptr list-ins iota1 list-cut
          lamxx
          optimizer:set-max-const-rank
          measure-time timer-tick
          to-file fprint fwrite
          
           PHYS:vrs:rpuvw
           PHYS:vrs:rhuvw
           PHYS:vrs:q
           PHYS:q
           PHYS:F
           PHYS:chrs
           PHYS:A
           PHYS:L
           PHYS:R
           PHYS:qlen
           PHYS:vect
           
           CGS CGS-lam
           2CGS 2CGS-lam
           
           set-scal
           
           PHYS:Potential
           
           MATH:Pi

           PHYS:gam
           PHYS:Rgas
           PHYS:G
        
           ASTRO:Rsun
           ASTRO:Msun
           ASTRO:OmegaK
           ASTRO:VK
           
           set-gam
           
           ADV:vm
           
           grid:cart
           grid:norm
           grid:join
           
           module-on
           def-int
           def-float
           
           add
           mul2
           map-ar
           arr-elements
           
           ADV:dF
           ADV:dF1
  )
  (import (guile)
          (grid-gen main)
          (grid-gen vars)
          (grid-gen code)
          (grid-gen phys)
          (grid-gen math)
          (grid-gen optimizer)
          (except (srfi srfi-1) map)
  )

(define-macro (def-int name . def)
  `(define ,name ,(append `(comp-int ,(symbol->string name)) def))
)

(define-macro (def-float name . def)
  `(define ,name ,(append `(comp-float ,(symbol->string name)) def))
)

(define-macro (module-on name . args)
  (append 
   `(begin (import (grid-gen ,name)))
    (if (not (null? args))
        (list
          (cons (string->symbol (string-append (symbol->string name) ":args"))
                args
          )
        )
       '()
    )
  )
)


)


